package objects.fields;

import java.io.IOException;
import java.io.RandomAccessFile;
import objects.DataObject;

public class IntegerVariable extends DataObject {
	public int value;

	public IntegerVariable( int fromValue ) {
		value = fromValue;
		this.gruClass = integerClass;
	}

	@Override
	public DataObject readValue( RandomAccessFile file ) throws IOException {
		return new IntegerVariable( file.readInt() );
	}

	@Override
	public void writeValue( RandomAccessFile file ) throws IOException {
		file.writeInt( value );
	}

	@Override
	public DataObject newObject() {
		return new IntegerVariable( 0 );
	}

	@Override
	public String toString() {
		return Integer.toString( value );
	}
	
	@Override
	public int toInteger() {
		return value;
	}
	
	@Override
	public String toCode( String indent ) {
		return String.valueOf( value );
	}
}